﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Net.Sockets;
using FatCatSniffer;
using System.IO;

namespace SocketSender
{
    class Program
    {
        private const int ServerPort = 14333;
        private static Server _server;
        private static TCPClientSender _sender;

        static void Main(string[] args)
        {
            _server = new Server(ServerPort);
            //_sender = new TCPClientSender(IPAddress.Parse("192.168.0.72"), ServerPort);
            _sender = new TCPClientSender(IPAddress.Parse("192.168.2.2"), ServerPort);

            StartSendClientMessagesThread(ServerPort);
        }

        private static void StartSendClientMessagesThread(int i)
        {
            //Action clientSendingProcess = SendMessageToClient;

            //clientSendingProcess.BeginInvoke(null, null);
            SendMessageToClient();
        }

        private static void SendMessageToClient()
        {
            while (true)
            {
                string userResponse = GetUserResponse();

                if (userResponse.ToLower() == ":q")
                {
                    break;
                }

                _sender.SendMessageToServer(userResponse);
            }
        }

        private static string GetUserResponse()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(Environment.NewLine);
            Console.Write("Message to send to server: ");
            return Console.ReadLine();
        }
    }
}
